#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 5005;
const int M = 5e5 + 5;
const int MOD = 80112002;
int n, m;
int head[N], deg[N], ans[N];
int ver[M], Next[M], tot;
void add(int u, int v) {
  ++tot;
  ver[tot] = v;
  Next[tot] = head[u];
  head[u] = tot;
}
int sum = 0;
void toposort() {
  queue<int> q;
  rep(i, 1, n) if (!deg[i]) q.push(i), ans[i] = 1;
  while (q.size()) {
    int u = q.front();
    q.pop();
    if (!head[u]) sum = (sum + ans[u]) % MOD;
    for (int i = head[u]; i; i = Next[i]) {
      int v = ver[i];
      ans[v] = (ans[v] + ans[u]) % MOD;
      if (!--deg[v]) q.push(v);
    }
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m;
  rep(i, 1, m) {
    int u, v;
    cin >> u >> v;
    add(u, v);
    deg[v]++;
  }
  toposort();
  cout << sum;
  return 0;
}